package com.chapter10.designmodel;

public class Hungry {
    public static void main(String[] args) {
        HungryMan instance = HungryMan.getInstance();
        System.out.println(instance);
    }
}


class HungryMan{

    private String name;

    private HungryMan(String name) {
        this.name = name;
    }

    private static HungryMan instance = new HungryMan("小红");

    public static HungryMan getInstance() {
        return instance;
    }

    @Override
    public String toString() {
        return "HungryMan{" +
                "name='" + name + '\'' +
                '}';
    }
}